<template>
  <div>
    <editor
      :initialValue="editorText"
      height="500px"
      initialEditType="markdown"
      previewStyle="vertical"
      ref="tuiEditor"
    />
    <div>
      <button @click='getHtml'>查看</button>
    </div>
    <viewer
      :initialValue="viewerText"
      height="500px"
    />
  </div>
</template>


<script>

import "codemirror/lib/codemirror.css";
import '@toast-ui/editor/dist/toastui-editor-viewer.css';
import "@toast-ui/editor/dist/toastui-editor.css";
// import 'tui-editor/dist/tui-editor.css';
// import 'tui-editor/dist/tui-editor-contents.css';
import { Editor, Viewer } from "@toast-ui/vue-editor";
// const { chart, codeSyntaxHighlight, colorSyntax, tableMergedCell, uml } = Editor.plugin;


export default {
  data() {
    return {
      editorText: "",
      viewerText: ""
    };
  },
  components: {
    editor: Editor,
    Viewer: Viewer
  },
  created() {
    this.viewerText = `  <p>12123123<strong>23123223</strong><del>123321</del></p>
  <table>
    <thead>
      <tr>
        <th>1</th>
        <th>2</th>
        <th>3</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>4</td>
        <td>2</td>
        <td>1</td>
      </tr>
    </tbody>
  </table>
  <p><img
      src=""
      alt="image"></p>`
  },
  methods: {
    sub() {
      // console.log(this.$refs.tuiEditor.$refs.toastuiEditor.innerHTML)
      console.log(this.editorText)
    },  
    getHtml() {
      let html = this.$refs.tuiEditor.invoke('getHtml')
      console.log(html)
    },
    scroll() {
      this.$refs.tuiEditor.invoke('scrollTop', 10)
    },
    moveTop() {
      this.$refs.tuiEditor.invoke('moveCursorToStart')
    },
  }
};
</script>

<style lang="scss" scoped>
</style>
